cp /etc/apt/sources.list /etc/apt/sources.list.bak
sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list
sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list
apt update
apt install -y git curl wget nano lsb-release
/python-rosdep2 python-rosinstall \
    python-rosinstall-generator python-wstool build-essential \
    nano lsb-release

sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
apt update
## 这里会有提示要写好非交互式安装
apt install -y ros-melodic-desktop-full
echo '185.199.110.133 raw.githubusercontent.com' | tee -a /etc/hosts
rosdep init
rosdep update
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc


cd /home
export ALL_PROXY="socks5://127.0.0.1:7897"
git clone -b v0.5 https://github.com/stevenlovegrove/Pangolin.git
git clone https://github.com/gaoxiang12/ORBSLAM2_with_pointcloud_map.git
git clone https://gitee.com/boboji11/robot_motion.git
unset ALL_PROXY
cd Pangolin
apt-get install -y libglew-dev
mkdir build && cd build
cmake -DCPP11_NO_BOOST=1 ..
make -j12
sudo make install
# opencv
apt-get install -y build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev \
        libswscale-dev libtbb2 libtbb-dev libpng-dev libtiff-dev libjasper-dev software-properties-common
add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
apt-get update
apt-get install -y libjasper-dev
# eigen3
apt-get install -y libeigen3-dev
echo 'export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/orb-slam2-pointcloud_map-modified/ORB_SLAM2_modified/Examples/ROS' >> ~/.bashrc
source ~/.bashrc
updatedb
rospack profile
echo ${ROS_PACKAGE_PATH} 

# pcl 1.10
apt-get install -y build-essential cmake git libboost-all-dev libeigen3-dev libflann-dev libglew-dev libqhull-dev libopenni2-dev libvtk7-dev

#test
./bin/rgbd_tum Vocabulary/ORBvoc.txt Examples/RGB-D/TUM1.yaml /home/dataset/orbslam/rgbd_dataset_freiburg1_desk Examples/RGB-D/associations/fr1_desk.txt
# orbbec camera
git clone https://github.com/orbbec/OrbbecSDK_ROS1.git
apt install -y libgflags-dev ros-$ROS_DISTRO-image-geometry ros-$ROS_DISTRO-camera-info-manager \
ros-${ROS_DISTRO}-image-transport-plugins ros-${ROS_DISTRO}-compressed-image-transport \
ros-$ROS_DISTRO-image-transport ros-$ROS_DISTRO-image-publisher libgoogle-glog-dev libusb-1.0-0-dev libeigen3-dev \
ros-$ROS_DISTRO-diagnostic-updater ros-$ROS_DISTRO-diagnostic-msgs \
libdw-dev
echo "source /home/ros_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc 

#test with camera
roslaunch orbbec_camera gemini.launch
rosrun ORB_SLAM2 RGBD /home/orb-slam2-pointcloud_map-modified/ORB_SLAM2_modified/Vocabulary/ORBvoc.txt \
/home/orb-slam2-pointcloud_map-modified/ORB_SLAM2_modified/Examples/RGB-D/TUM1.yaml 
mv /home/orb-slam2-pointcloud_map-modified/ORB_SLAM2_modified/vslam.pcd /home/dataset/vslam2.pcd
cp /home/orb-slam2-pointcloud_map-modified/ORB_SLAM2_modified/vslam.pcd /home/dataset/vslam2.pcd
## test with gdb
gdb /home/orb-slam2-pointcloud_map-modified/ORB_SLAM2_modified/Examples/ROS/ORB_SLAM2/RGBD
(gdb) set args /home/orb-slam2-pointcloud_map-modified/ORB_SLAM2_modified/Vocabulary/ORBvoc.txt \
/home/orb-slam2-pointcloud_map-modified/ORB_SLAM2_modified/Examples/RGB-D/TUM1.yaml 
(gdb) run